package com.zuihai.app.mvp.ui.utils;

import com.zuihai.app.mvp.model.entity.InitUser;

import org.litepal.crud.DataSupport;

/**
 * Created by Administrator on 2017/6/12 0012.
 */

public class UserDataUtils {
    private InitUser initUser;
    private String uid;
    private String headImage;
    private static UserDataUtils mInstance;

    private UserDataUtils() {
    }

    public static UserDataUtils getInstance() {
        if (mInstance == null) {
            synchronized (AccountHelper.class) {
                if (mInstance == null) {
                    mInstance = new UserDataUtils();
                }
            }
        }
        return mInstance;
    }

    /**
     * 获取用户的全部信息
     *
     * @return
     */
    public InitUser getUserData() {
        initUser = DataSupport.findFirst(InitUser.class);
        return initUser;
    }

    /**
     * 获取用户的ID
     *
     * @return
     */
    public static String getUserID() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        String uid = "";
        if (initUser != null) {
            uid = initUser.getUid();
            return uid;
        }

        return uid;
    }

    /**
     * 获取用户的renzheng tag
     *
     * @return
     */
    public static String getRenzheng() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        String renzhengTag = "";
        if (initUser != null) {
            renzhengTag = initUser.getRenzhengTag();
            return renzhengTag;
        }

        return renzhengTag;
    }

    /**
     * 获取用户的性别
     *
     * @return
     */
    public static String getUserSex() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        String uid = "女";
        if (initUser != null) {
            uid = initUser.getGender();
            return uid;
        }

        return uid;
    }

    /**
     * 获取用户的电话
     *
     * @return
     */
    public static String getUserPhoneNumber() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        String uid = "";
        if (initUser != null) {
            uid = initUser.getPhoneNumber();
            return uid;
        }
        return uid;
    }


    /**
     * 获取用户的微信账号
     *
     * @return
     */
    public static String getUserWeChat() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        String uid = "1";
        if (initUser != null) {
            uid = initUser.getWeChat();
            return uid;
        }

        return uid;
    }


    /**
     * 获取用户的支付宝账号
     *
     * @return
     */
    public static String getUserAli() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        String uid = "1";
        if (initUser != null) {
            uid = initUser.getAli();
            return uid;
        }

        return uid;
    }

    public String userID() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        String uid = "1";
        if (initUser != null) {
            uid = initUser.getUid();
            return uid;
        }

        return uid;
    }

    public static int getType(){
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        if (initUser != null) {
            int headImage = initUser.getType();
            return headImage;

        }
        return 5;
    }
    public static String getUserHeadImage() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        if (initUser != null) {
            String headImage = initUser.getIcon();
            return headImage;

        }
        return "";
    }


    public static String getUserSignature() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        if (initUser != null) {
            String signature = initUser.getQianMing();
            if (signature != null&&!signature.isEmpty()) {
                return signature;
            } else {
                return "";
            }
        }
        return "";
    }

    public static String getUserBackground() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        if (initUser != null) {
            String background = initUser.getBackground();
            if (background != null&&!background.isEmpty()) {
                return background;
            } else {
                return "";
            }
        }
        return "";
    }

    public static String getUserNickName() {
        InitUser initUser = DataSupport.findFirst(InitUser.class);
        if (initUser != null) {
            String nickname = initUser.getName();
            if (nickname != null&&!nickname.isEmpty()) {
                return nickname;
            } else {
                return "";
            }

        }
        return "";
    }
}
